package com.zhuanzhuan.hero.user.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @ClassName AuditStateEnum
 * @Description
 * @Author hanjunjun
 * @Date 2024/6/27 20:39
 */
@Getter
public enum AuditStateEnum {

    WAIT_AUDIT(0, "待审核"),
    REJECT(10, "审核驳回"),
    PASS(20, "审核通过")
    ;

    private final Integer code;

    private final String name;

    AuditStateEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private static final Map<Integer, String> CODE_NAME_MAP = new HashMap<>();

    static {
        for (AuditStateEnum anEnum : AuditStateEnum.values()) {
            CODE_NAME_MAP.put(anEnum.getCode(), anEnum.name);
        }
    }

    public static String getNameByCode(Integer code) {
        if (Objects.isNull(code)) {
            throw new IllegalArgumentException();
        }
        return CODE_NAME_MAP.get(code);
    }
}
